package rule

import "regexp"

func init() {
	Register(&chsRule{Regexp: regexp.MustCompile(`^[\p{Han}]+$`)})
}

type chsRule struct {
	*regexp.Regexp
}

func (c *chsRule) Name() string {
	return "chs"
}

func (c *chsRule) Check(in *RuleInput) (err error) {
	if v, ok := in.Value.(string); ok && v != "" && c.FindStringIndex(v) != nil {
		return
	}
	return in.Error()
}
